<template>
	<view class="discount-info_page">
		<view class="content">
			<view class="grade_row">
				<view class="row">
					<view class="row_title">用户名</view>
					<input class="row_content" type="text" v-model="memInfo.memberName" />
				</view>
			</view>
			<view class="grade_row">
				<view class="row">
					<view class="row_title">会员类型</view>
					<view class="row_content">散户</view>
					<!--  <view class="row_content" v-if="memInfo.memberType==2">企业总账户</view>
                    <view class="row_content" v-if="memInfo.memberType==3">企业子账户</view> -->
				</view>
			</view>
			<view class="grade_row">
				<view class="row">
					<view class="row_title">手机号码</view>
          <view class="row_content">{{memInfo.phoneNum}}</view>
<!--					<input class="row_content" type="text" v-model="memInfo.phoneNum" />-->
				</view>
			</view>
			<view class="grade_row">
				<view class="row">
					<view class="row_title">所属企业</view>
					<view class="row_content">无</view>
				</view>
			</view>
			<view class="grade_row">
				<view class="row">
					<view class="row_title">身份证号</view>
					<input class="row_content" type="text" v-model="memInfo.idCard" />
				</view>
			</view>
			<view class="grade_row">
				<view class="row">
					<view class="row_title">绑定车牌</view>
					<input class="row_content" type="text" v-model="memInfo.carNo" />
				</view>
			</view>
			<view class="grade_row">
				<view class="row">
					<view class="row_title">卡号</view>
					<view class="row_content">{{memInfo.memberCard}}</view>
				</view>
			</view>
			<view class="grade_row">
				<view class="row">
					<view class="row_title">卡片等级</view>
					<view class="row_content">{{memInfo.gradeName}}</view>
				</view>
			</view>
		</view>
		<view class="submit">
			<button type="default" @click="getEditUserInfo()">保存</button>
		</view>
	</view>
</template>

<script>
	import {
		editUserInfo,
		getMember
	} from '@/api/index.js'
	import {
		showConfirm
	} from '@/utils/common'
	export default {
		data() {
			return {
				memInfo: {}
			};
		},
		onLoad(option) {
			getMember({
				openId: uni.getStorageSync('userOpenId')
			})
			// this.memInfo = JSON.parse(option.memberVo)
			let memberInfo = JSON.parse(uni.getStorageSync('memberInfo'))
			this.memInfo = memberInfo.memberVo.member
		},
		methods: {
			getEditUserInfo() {
				uni.showLoading({
					title: '修改中...'
				})
				// this.memInfo.openId = uni.getStorageSync('userOpenId')
				editUserInfo(this.memInfo).then(res => {
					uni.hideLoading()
					if (res.code == 200) {
						showConfirm('修改成功，确定返回个人中心').then(res => {
							if (res.confirm) {
								uni.navigateBack(1)
								// uni.reLaunch({
								// 	url:'/pages/personal-center/index'
								// })
							}
						})
					}
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	.discount-info_page {
		padding-top: 18rpx;
		padding-bottom: 18rpx;

		.content {
			background-color: #ffffff;

			.grade_row {
				padding: 0rpx 24rpx;
				border-bottom: 1px solid #ededed;

				.row {
					display: flex;
					align-items: center;
					line-height: 98rpx;

					.row_title {
						font-size: 30rpx;
						color: #333333;
						font-weight: 600;
						line-height: 98rpx;
						width: 20%;
					}

					.row_content {
						font-size: 30rpx;
						font-weight: 500;
						color: #333333;
						line-height: 30rpx;
						margin-left: 72rpx;
					}
				}
			}

			.grade_row:nth-last-child(1) {
				border-bottom: none;
			}
		}

		.title {
			font-size: 26rpx;
			color: #999999;
			line-height: 30rpx;
			padding: 24rpx 0rpx 24rpx 24rpx;
		}

		.submit {
			button {
				line-height: 80rpx;
				width: 80%;
				background-color: #1f63f4;
				margin: 30rpx auto;
				color: white;
			}
		}
	}
</style>